<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui"
    />
    <title>登录页</title>
    <link rel="shortcut icon" type="image/x-icon" href="../favicon.ico" />
    <link
      rel="stylesheet"
      type="text/css"
      href="../css/materialdesignicons.min.css"
    />
    <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/animate.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.min.css" />
    <style></style>
  </head>

  <body class="bg-white overflow-x-hidden">
    <div class="row bg-white vh-100">
      <div
        class="col-md-6 col-lg-7 col-xl-8 d-none d-md-block"
        style="
          background-image: url(../images/login-bg-1.jpg);
          background-size: cover;
        "
      >
        <div class="d-flex vh-100">
          <div class="p-5 align-self-end">
            <img src="../images/gwlogo.png" alt="..." />
            <br /><br /><br />
            <p class="text-white">成都软件技术专修学院--学籍管理系统</p>
          </div>
        </div>
      </div>

      <div class="col-md-6 col-lg-5 col-xl-4 align-self-center">
        <div class="p-5">
          <div class="text-center">
            <a href="index.html">
              <img alt="light year admin" src="../images/gwlogo-sidebar.png" />
            </a>
          </div>
          <p class="text-center text-muted">
            <small>请使用您的账号登录系统</small>
          </p>

          <form
            action="/login"
            method="post"
            class="signin-form needs-validation"
            novalidate
          >
            <div class="position-relative mb-3">
              <label for="username" class="form-label">用户名</label>
              <input
                type="text"
                class="form-control"
                id="username"
                name="username"
                placeholder="请输入您的用户名"
                required
              />
              <div
                class="invalid-feedback position-absolute top-0 end-0 w-auto"
              >
                请输入用户名...
              </div>
            </div>

            <div class="position-relative mb-3">
              <label for="password" class="form-label">密码</label>
              <input
                type="password"
                class="form-control"
                id="password"
                name="password"
                placeholder="请输入您的密码"
                required
              />
              <div
                class="invalid-feedback position-absolute top-0 end-0 w-auto"
              >
                请输入密码...
              </div>
            </div>

            <!-- <div class="position-relative mb-3">
              <label for="email" class="form-label">邮箱</label>
              <input
                type="email"
                class="form-control"
                id="email"
                name="email"
                placeholder="请输入您的邮箱"
                required
              />
              <div
                class="invalid-feedback position-absolute top-0 end-0 w-auto"
              >
                请输入邮箱...
              </div>
            </div>

            <div class="position-relative mb-3">
              <label for="check" class="form-label">验证码</label>
              <div class="row">
                <div class="col-auto">
                  <input
                    type="text"
                    class="form-control"
                    id="check"
                    placeholder="请输入您的验证码"
                    required
                  />
                  <div
                    class="invalid-feedback position-absolute top-0 end-50 w-auto"
                  >
                    请输入验证码...
                  </div>
                </div>
                <div class="col-auto">
                  <button class="btn btn-primary">发送验证码</button>
                </div>
              </div>
            </div> -->

            <div class="mb-3 d-grid">
              <button class="btn btn-primary" type="submit">立即登录</button>
            </div>
          </form>
        </div>
      </div>
    </div>
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/popper.min.js"></script>
    <script type="text/javascript" src="../js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../js/lyear-loading.js"></script>
    <script type="text/javascript" src="../js/bootstrap-notify.min.js"></script>
    <script type="text/javascript">
      var loader
      $(document)
        .ajaxStart(function () {
          $('button:submit').html('登录中...').attr('disabled', true)
          loader = $('button:submit').lyearloading({
            opacity: 0.2,
            spinnerSize: 'nm',
          })
        })
        .ajaxStop(function () {
          loader.destroy()
          $('button:submit').html('立即登录').attr('disabled', false)
        })
      $('.signin-form').on('submit', function (event) {
        if ($(this)[0].checkValidity() === false) {
          event.preventDefault()
          event.stopPropagation()
          $(this).addClass('was-validated')
          return false
        }

        var $data = $(this).serialize() // 将表单值序列化URL字符串

        $.post($(this).attr('action'), $data, function (res) {
          if (res.code) {
            // 这里没有后端地址，就直接假设成功
            // if (true) {
            $.notify(
              {
                message: '登录成功，页面即将跳转~',
              },
              {
                type: 'success',
                placement: {
                  from: 'top',
                  align: 'right',
                },
                z_index: 10800,
                delay: 1500,
                animate: {
                  enter: 'animate__animated animate__fadeInUp',
                  exit: 'animate__animated animate__fadeOutDown',
                },
              }
            )
            setTimeout(function () {
              location.href = 'html/index.html'
            }, 1500)
          } else {
            $.notify(
              {
                message: '登录失败，错误原因：' + res.msg,
              },
              {
                type: 'danger',
                placement: {
                  from: 'top',
                  align: 'right',
                },
                z_index: 10800,
                delay: 1500,
                animate: {
                  enter: 'animate__animated animate__shakeX',
                  exit: 'animate__animated animate__fadeOutDown',
                },
              }
            )
            $('#password').val('')
            $('#captcha').click()
          }
        }).fail(function () {
          $.notify(
            {
              message: '服务器错误',
            },
            {
              type: 'danger',
              placement: {
                from: 'top',
                align: 'right',
              },
              z_index: 10800,
              delay: 1500,
              animate: {
                enter: 'animate__animated animate__shakeX',
                exit: 'animate__animated animate__fadeOutDown',
              },
            }
          )
        })

        return false
      })
    </script>
  </body>
</html>
